livepatch: Add support for inline asm livepatching expectations
authorPawel Wieczorkiewicz <wipawel@amazon.de>
Tue, 26 Nov 2019 10:07:57 +0000 (10:07 +0000)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Fri, 13 Dec 2019 14:45:32 +0000 (14:45 +0000)
commit8e24c887887a95cb2dda0017569ed19b65670152
tree00c87e2fe0b31da7960a1d66a35a4701b29478ea
parent6047104c3ccc50205464a9b6a90daa85d21a4798
livepatch: Add support for inline asm livepatching expectations

This is the initial implementation of the expectations enhancement
to improve inline asm livepatching.

Expectations are designed as optional feature, since the main use of
them is planned for inline asm livepatching. The flag enabled allows
to control the expectation state.
Each expectation has data and len fields that describe the data
that is expected to be found at a given patching (old_addr) location.
The len must not exceed the data array size. The data array size
follows the size of the opaque array, since the opaque array holds
the original data and therefore must match what is specified in the
expectation (if enabled).

The payload structure is modified as each expectation structure is
part of the livepatch_func structure and hence extends the payload.

Each expectation is checked prior to the apply action (i.e. as late
as possible to check against the most current state of the code).

For the replace action a new payload's expectations are checked AFTER
all applied payloads are successfully reverted, but BEFORE new payload
is applied. That breaks the replace action's atomicity and in case of
an expectation check failure would leave a system with all payloads
reverted. That is obviously insecure. Use it with caution and act
upon replace errors!

Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Andra-Irina Paraschiv <andraprs@amazon.com>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
Reviewed-by: Norbert Manthey <nmanthey@amazon.de>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
.gitignore
docs/misc/livepatch.pandoc
xen/common/livepatch.c
xen/include/public/sysctl.h
xen/test/livepatch/Makefile
xen/test/livepatch/xen_expectations.c [new file with mode: 0644]
xen/test/livepatch/xen_expectations_fail.c [new file with mode: 0644]